<?php use_helper("i18n")?>
<div class="delayload">
	<div id="inner-tab" class="border">
	<?php if( $datas && count( $datas ) > 0 ):?>
		<div class="navbg">
        	<div class="h-province"><?php echo TMDService::renderI18n( $province, "getSname", $sf_user->getCulture() )?></div>
			<ul class="nav right">
				<?php foreach( $stations as $station ):?>
					<li data-tab="tab-province-<?php echo $station->getIstationId()?>" <?php echo $station->getIstationId() == $province->getIstationId()? "class=\"active v_active\"": ""?>><?php echo TMDService::renderI18n( $station, "getSstationName", $sf_user->getCulture())?></li>
				<?php endforeach;?>
			</ul>
		</div>
		<div class="container">
			<div class="content">
				
				<?php foreach( $datas as $stationId => $data ):?>
					<?php if( $data ) :?>
						<h3 class="v_nav<?php echo $stationId == $province->getIstationId()? " v_active": ""?>" data-tab="tab-province-1">tab-province-<?php echo $data->getIstationId()?></h3>
						<div id="tab-province-<?php echo $stationId?>" class="tab_content">
						    <div class="all-content">
						        <div class="content-inner-tab">
						            <div class="h-inner-tab-b"><?php echo __("Current Weather")#สภาพอากาศปัจจุบัน?></div>
						            <div class="big-blue-txt"><?php echo $data->getNbarometerTemperature()?>&#8451;</div>
						            <div class="clear"></div>
						            <ul class="inner-tab-list">
						                <li><?php //$data = new Input3hour()?>
						                    <div class="h-inner-tab-b"><?php echo __("Dew point")#จุดน้ำค้าง?></div>
						                    <div class="blue-tab-txt">
						                    <?php if( $data->getNdewPoint() > 0.0 ):?>
						                    	<?php echo sprintf( "%0.1f &#8451;", $data->getNdewPoint() )?>
						                    <?php else:?>
						                    	-
						                    <?php endif;?>
						                    </div>
						                </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Relative Humidity")#ความชื้นสัมพัทธ์?></div>
						                    <div class="blue-tab-txt"><?php echo sprintf("%d %%", $data->getNdryBulb_temperature() )?></div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Wind")#ลม?></div>
						                    <div class="blue-tab-txt">
							                    <?php if( $data->getNwindSpeed() == 0 ):?>
							                    	<?php //echo __("ลมสงบ")#ลมสงบ?>-
												<?php else:?>
													<?php echo sprintf( "%s/%0.1f " . __("kph"), $data->getSwindDirection(), 1.85325 * $data->getNwindSpeed() )?>
												<?php endif;#กม./ชม.?>
						                    </div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Cloud")#เมฆ?></div>
						                    <div class="blue-tab-txt"><?php echo TMDService::getCloudDescription( $data->getNtotalCloud_amount() )?>ท้องฟ้าโปร่ง</div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Visibility")#ทัศนวิสัย?></div>
						                    <div class="blue-tab-txt"><?php echo sprintf( "%0.1f " . __("km"), $data->getNlandVisibility() )?><?php echo ''#กม.?></div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Pressure")#ความกดอากาศ?></div>
						                    <div class="blue-tab-txt"><?php echo sprintf( "%0.1f hPa", $data->getNmslPressure() )?></div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Amout of Rainfall (3hr)")#ฝน 3 ชม?></div>
						                    <div class="blue-tab-txt">
						                        <?php if( $data->getNrainfall() > 0 && $data->getNrainfall() < 0.1 ):?>
						                        	<?php //echo __("")#เล็กน้อยวัดไม่ได้?><?php echo sprintf("%0.01f " . __("mm"), $data->getNrainfall() )?>
						                        <?php else:?>
						                        	<?php echo sprintf("%0.01f " . __("mm"), $data->getNrainfall() )?>
						                        <?php endif;?>
					                        </div>
					                    </li>
						            </ul>
						            <ul class="inner-tab-list right">
						            	<?php
						            	$c = new Criteria();
						            	$c->add( StationsPeer::ISTATION_ID, $stationId );
						            	$station = StationsPeer::doSelectOne( $c );
						            	
						            	$latitude = $station->getIlatitudeDegree() + $station->getIlatitudeMinute() / 60 + $station->getIlatitudeSecond() / 3600;
						            	$longitude = $station->getIlongitudeDegree() + $station->getIlongitudeMinute() / 60 + $station->getIlongitudeSecond() / 3600;
						            	?>
						                <li>
						                    <div class="h-inner-tab-b"><?php echo __("Tomorrow Sunrise")#พระอาทิตย์ขึ้นเช้าพรุ่งนี้?></div>
						                    <div class="blue-tab-txt"><?php echo TMDService::sunrise( $latitude, $longitude )?> น.</div>
						                </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Today Sunset")#พระอาทิตย์ตกเย็นวันนี้?></div>
						                    <div class="blue-tab-txt"><?php echo TMDService::sunset( $latitude, $longitude )?> น.</div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Yesterday Max Temperature")#อุณหภูมิสูงสุดวานนี?></div>
						                    <div class="blue-tab-txt">
						                    <?php if( $data->getNmaxTemperature() && $data->getNmaxTemperature() > 0.0 ):?>
						                    	<?php echo sprintf("%0.1f &#8451;", $data->getNmaxTemperature() )?>
					                    	<?php else:?>
					                    		-
					                    	<?php endif;?>
						                    </div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php echo __("Morning Min Temperature")#อุณหภูมิต่ำสุดเช้าวันนี้?></div>
						                    <div class="blue-tab-txt">
						                    <?php if( $data->getNminTemperature() && $data->getNminTemperature() > 0.0 ):?>
						                    	<?php echo sprintf("%0.1f &#8451;", $data->getNminTemperature() )?>
						                    <?php else:?>
						                    	-
						                    <?php endif;?>
						                    </div>
					                    </li>
						                <li>
						                	<div class="h-inner-tab-b"><?php //echo __("Average Max Temperature")#อุณหภูมิสูงสุดวานนี?></div>
						                    <div class="blue-tab-txt"><?php //echo sprintf("%0.1f &#8451;", $data->getNa() )?></div>
					                    </li>
						            </ul>
						        </div>
						    </div>
						</div>
					<?php endif;?>
				<?php endforeach;?>
			</div>
		</div>
		<?php endif;?>
	<!-- /tab-province-1 -->
	</div>
</div>
<!-- Inner Tab-->
<?php if( isset( $longStays ) && count( $longStays ) > 0 ):?>
	<div class="box-weather-week">
		<div class="header-box-week">
			<div class="fleft"><img src="<?php echo image_path("/images/bg-h-province-start.png")?>" width="9" height="34"></div>
			<div class="header-box-week-txt"><span><?php echo __("Weekly Forecast")#พยากรณ์อากาศรายสัปดาห์?></span></div>
			<div class="fleft"><img src="<?php echo image_path("/images/bg-h-province-end.png")?>" width="17" height="34"></div>
		</div>
		<div class="clear"></div>
		<ul class="content-box-week">
			<?php foreach ( $longStays as $longStay ):?>
				<?php //$longStay = new InputLongStay()?>
				<li>
					<div>
						<div class="date-txt">
						<?php echo sprintf( "%s - %s", TMDService::toThaiDate( $longStay->getDttimeForecastFrom() ), TMDService::toThaiDate( $longStay->getDttimeForecastTo() ) )?>
						</div>
						<img src="<?php echo image_path( "/images/icon/weather" . $longStay->getIweatherType() . ".png" )?>" width="100" height="100">
						<div class="txt"><?php echo __("Avg Max")#สูงสุดเฉลี่ย?> <span class="red"><?php echo sprintf( "%d - %d &#8451;", $longStay->getItempMaxLowbound(), $longStay->getItempMaxHighbound() )?></span></div>
						<div class="txt"><?php echo __("Avg Min")#ต่ำสุดเฉลี่ย?> <span class="blue"><?php echo sprintf( "%d - %d &#8451;", $longStay->getItempMinLowbound(), $longStay->getItempMinHighbound() )?></span></div>
					</div>
				</li>
			<?php endforeach;?>
		</ul>
	</div>
<?php endif;?>
